#include "SSYieldCurve.h"

CSSYieldCurve::CSSYieldCurve() {}

CSSYieldCurve::~CSSYieldCurve() {}

// Return a yield curve pointer per given bond data and yield curve type
// The caller needs to delete the pointer!
BondYieldCurve* CSSYieldCurve::GetParCurve(
    const std::vector<YCInfo>& bondData,
    const int yieldDate,   // Input: Date the curve represents. format:yyyymmdd,
                           // ie:20130507
    YieldCurveType ycType  // Input: Curve type
) {
  return RateBondAnalysis::GetInstance()->GetParCurve(bondData, yieldDate,
                                                      ycType);
}

// Return a vector of interpolated yield curve points from give quotes
int CSSYieldCurve::GetYieldCurvePoints(
    const std::vector<YCInfo>& bondData,
    const int
        yieldDate,  // Date the curve represents. format:yyyymmdd, ie:20130507
    std::vector<double>
        samplingMat,  // Sampling vector which contains remaining maturities
    YieldCurveType ycType,  // Curve type
    std::vector<YieldPoints>&
        samplingMatYields  // Output: Yields vector corresponding to the
                           // sampling maturities
) {
  return RateBondAnalysis::GetInstance()->GetYieldCurvePoints(
      bondData, yieldDate, samplingMat, ycType, samplingMatYields);
}

// Return a vector of interpolated yield curve points
int CSSYieldCurve::GetYieldCurvePoints(
    const std::vector<YCInfo>& bondData,
    const int yieldDate,    // Date the curve represents. format:yyyymmdd
    int countSamplingPts,   // Number of sampling points
    YieldCurveType ycType,  // Curve type
    std::vector<YieldPoints>&
        samplingMatYields  // Output: Yields vector corresponding to the
                           // sampling maturities
) {
  return RateBondAnalysis::GetInstance()->GetYieldCurvePoints(
      bondData, yieldDate, countSamplingPts, ycType, samplingMatYields);
}

// InterpolatedBondYTMCurve* CSSYieldCurve::GetYieldCurve(const
// std::vector<YCInfo>& bondData, const int yieldDate)
//{
//	return
//RateBondAnalysis::GetInstance()->GetYieldCurve(bondData,yieldDate);
// }

// Return a vector of spreads between source curve and benchmark
int CSSYieldCurve::GetYieldSpreads(
    const std::vector<YCInfo>& bondDataBHM,  // Benchmark yield curve data
    YieldCurveType bhmType,                  // Benchmark yield curve type
    const std::vector<YCInfo>& bondDataSrc,  // Source yield curve data
    YieldCurveType srcType,                  // Source yield curve type
    const int
        yieldDate,  // Date the curve represents. format:yyyymmdd, ie:20130507
    const int nSpreadPts,  // Number of spread points
    std::vector<YieldPoints>&
        spreads  // Output: Spreads vector between source curve and benchmark
) {
  return RateBondAnalysis::GetInstance()->GetYieldSpreads(
      bondDataBHM, bhmType, bondDataSrc, srcType, yieldDate, nSpreadPts,
      spreads);
}

// Return a vector of zero curve points from give quotes
// 返回值 = 0， 成功; 返回值 != 0,
// 失败。根据返回值调用ErrorMessage()可以找到相应的错误消息
int GetZeroCurvePoints(
    const std::vector<YCInfo>& bondData,
    const int yieldDate,  // Input: Date the curve represents. format:yyyymmdd,
                          // ie:20130507
    int count,            // Input: Number of sampling points
    std::vector<YieldPoints>& curvePoints,  // Output: Yields vector
    YieldCurveType ycType = GOV_BOND        // Input: Curve type
) {
  return RateBondAnalysis::GetInstance()->GetZeroCurvePoints(
      bondData, yieldDate, count, curvePoints, ycType);
}

// Return a yield curve pointer per given bond data and yield curve type
// The caller needs to delete the pointer!
BondYieldCurve* GetZeroCurve(
    const std::vector<YCInfo>& bondData,
    const int yieldDate,  // Input: Date the curve represents. format:yyyymmdd,
                          // ie:20130507
    YieldCurveType ycType = GOV_BOND  // Input: Curve type
) {
  return RateBondAnalysis::GetInstance()->GetZeroCurve(bondData, yieldDate,
                                                       ycType);
}

double AfxGetRemainingMaturity(int startDate, int endDate) {
  return GetRemainingMaturity(startDate, endDate);
}

void AfxFillMissingData(std::vector<double>& yields) {
  return FillMissingData(yields);
}
